<!-- 系统角色首页 -->
<template>

  <div class="app-container">
    <!-- 左侧 菜单列表-->
    <el-row :gutter="15">
      <el-col :sm="24" :md="18" style="margin-bottom: 10px">
        <el-card class="box-card" style="height: 100% ">
          <div slot="header" class="clearfix">
            <span>角色列表</span>
          </div>
          <LeftIndex style="padding: 1px" @selectedChanged="selectedChanged" />
        </el-card>
      </el-col>
      <!-- 右侧 菜单详情-->
      <el-col v-if="permission.has('SysRoleMenu:query')" :sm="24" :md="6">
        <el-card class="box-card" style="height: 100%">
          <div slot="header" class="clearfix">
            <span v-if="roleId" style="color: #ff4949">【{{ roleName }}】</span>
            <span v-if="!roleId" style="color: #1f2e46">请选择角色进行 </span>
            <span>权限绑定</span>
            <label style="float: right;padding: 4px 10px;margin-top: -10px">
              <el-button
                v-if="roleId && permission.has('SysRoleMenu:add')"
                slot="reference"
                class="filter-item"
                type="primary"
                icon="el-icon-check"
                size="mini"
                @click="saveRoleWithMenu"
              >
                保存
              </el-button>
            </label>
          </div>
          <div>
            <RightIndex ref="rightIndex" style="padding: 1px" :role-id="roleId" :code="code" />
          </div>
        </el-card>
      </el-col>
    </el-row>

  </div>
</template>
<!-- 系统角色 首页-->
<script>
import LeftIndex from './leftIndex'
import RightIndex from './rightIndex'
export default {
  name: 'SysRole',
  components: {
    LeftIndex,
    RightIndex
  },
  data() {
    return {
      permission: new Map(),
      roleId: '',
      roleName: '',
      code: null
    }
  },
  mounted() {
    this.permission = this.$store.state.menu.buttonPermission.get('SysRole')
  },
  methods: {
    selectedChanged(roleId, roleName, code) {
      this.roleId = roleId
      this.roleName = roleName
      this.code = code
    },
    saveRoleWithMenu() {
      this.$refs.rightIndex.saveRoleWithMenu()
    }
  }
}
</script>

<style scoped>

</style>
